package SM::Server::Packet::In::Chat::Message;

use strict;
use warnings;

use Data::Dumper::Simple;

use SM::Constants;

use base 'SM::Server::Packet::In::Chat';

sub new {
	my ( $class, $arg_ref ) = @_;

	my $self = $class->SUPER::new($arg_ref);

	$self->{sub_type} = CHAT_MESSAGE;

	my ( $data_type, $sub_type, $reciever_type, $sender, $reciever, $message )
		= unpack "CCCZ*Z*Z*", $arg_ref->{raw_data};

	$self->{reciever_type} = $reciever_type;
	$self->{sender}        = $sender;
	$self->{reciever}      = $reciever;
	$self->{message}       = $message;

	return $self;
}

sub dispatch {
	my ($self) = @_;

	# Send data to be processed 
	SM::Server::GameLogic::chat_handle_message->(
		{   reciever_type => $self->{reciever_type},
			sender        => $self->{sender},
			reciever      => $self->{reciever},
			message       => $self->{message},
		}
	);

}

1;
